package com.zmj.sy.mom.srv.aps.utils.schedulerole.impl;

import com.zmj.sy.mom.srv.aps.bean.bo.CacheFactory;
import com.zmj.sy.mom.srv.aps.bean.entity.order.ApsBatch;
import com.zmj.sy.mom.srv.aps.bean.entity.order.ApsOrder;
import com.zmj.sy.mom.srv.aps.bean.entity.order.Order;
import com.zmj.sy.mom.srv.aps.bean.vo.apsorder.ApsOrderScheduleReqVo;
import com.zmj.sy.mom.srv.aps.utils.schedulerole.ScheduleRole;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;


@Slf4j
@RequiredArgsConstructor
@Component
public class OrderWeightScheduleRole implements ScheduleRole {

    @Override
    public List<ApsOrder> sort(List<ApsOrder> apsOrders, ApsOrderScheduleReqVo reqVo) {
        return apsOrders.stream().sorted(Comparator.comparing(ApsOrder::getOrderPriority).reversed().thenComparing(ApsOrder::getOrderWeight).reversed()).collect(Collectors.toList());
    }
    @Override
    public List<ApsOrder> sort(CacheFactory reqVo, ApsBatch batch, List<Order> orders) {
        return Collections.emptyList();
    }
    @Override
    public Integer getMyCode() {
        return ORDER_WEIGHT;
    }
}
